from langchain.prompts import ChatMessagePromptTemplate
from langchain.prompts import MessagesPlaceholder
from langchain_core.messages import HumanMessage
from langchain_core.prompts import HumanMessagePromptTemplate, ChatPromptTemplate


def rolePromptTemplate(prompt,role,dict):
    """
    用于创建多角色对话
    :param prompt:创建角色的对话替换词用‘{xxx}’替换    #图图啊，今天晚上打{subject}呀
    :param role:创建角色名
    :param dict:替代词   #{'subject':"瓦罗兰特"}
    :return:返回一个自定义角色模板
    """
    prompt = prompt
    chat_message_prompt = ChatMessagePromptTemplate.from_template(role=role, template=prompt)
    chat_message_prompt.format(**dict)
    return chat_message_prompt

if __name__ == '__main__':
    chat_prompt = rolePromptTemplate("图图啊，今天晚上打{subject}呀","牛爷爷",{'subject':"瓦罗兰特"})